
<%@ page import="com.surelution.projects.crm.OwnStation" %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="layout" content="main" />
        <g:set var="entityName" value="${message(code: 'ownStation.label', default: 'OwnStation')}" />
        <title><g:message code="default.list.label" args="[entityName]" /></title>
    </head>
    <body>
        <div class="nav">
            <span class="menuButton"><a class="home" href="${createLink(uri: '/')}"><g:message code="default.home.label"/></a></span>
        </div>    
				
        <div class="body">

            <h1><g:message code="default.list.label" args="[entityName]" /></h1>
            <g:if test="${flash.message}">
            <div class="message">${flash.message}</div>
            </g:if>
            <div class="list">
                <table>
                    <thead>
                        <tr>
                            <g:sortableColumn property="stationArea" title="${message(code: 'ownStation.stationArea.label', default: 'stationArea')}" />
                        
                            <g:sortableColumn property="name" title="${message(code: 'ownStation.name.label', default: 'Name')}" />

                            <g:sortableColumn property="code" title="${message(code: 'ownStation.code.label', default: 'Code')}" />

                            <g:sortableColumn property="manager" title="${message(code: 'ownStation.manager.label', default: 'manager')}" />
                            
                            <th style="color:white;font-size:12px;font-weight:bold;"><g:message code="ownStation.level.label"/></th>
                        
                            <th style="color:white;font-size:12px;font-weight:bold;"><g:message code="ownStation.star.label"/></th>

                            <th style="color:white;font-size:12px;font-weight:bold;"><g:message code="ownStation.tonLevel.label"/></th>
                        
	                        <g:sortableColumn property="isLocked" title="${message(code: 'market.isLocked.label', default: 'isLocked')}" />

                            <g:sortableColumn property="isLocked" title="${message(code: 'market.operation.label', default: 'operation')}" />
                        
                            <th style="color:white;font-size:12px;font-weight:bold;"><g:message code="ownStation.isActived.label"/></th>
                        </tr>
                    </thead>
                    <tbody>
                    <g:each in="${ownStationInstanceList}" status="i" var="ownStationInstance">
                        <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
                            <td>${fieldValue(bean: ownStationInstance, field: "stationArea.areaName")}</td>

                            <td><g:link action="show" id="${ownStationInstance.id}">${ownStationInstance.name.startsWith("浙江销售嘉兴分公司")?ownStationInstance.name[9 .. ownStationInstance.name.length() - 1]:ownStationInstance.name}</g:link></td>

                            <td>${fieldValue(bean: ownStationInstance, field: "code")}</td>

                            <td>${fieldValue(bean: ownStationInstance, field: "manager")}</td>

                            <td>
							   	<g:if test="${ownStationInstance.level.title.size()>3}"><label title="${ownStationInstance.level.title}">${ownStationInstance.level.title.substring(0,3)}</label> </g:if>
                            	<g:if test="${ownStationInstance.level.title.size()<3}"><label title="${ownStationInstance.level.title}">${ownStationInstance.level.title}</label></g:if>
                            </td>

                            <td>${fieldValue(bean: ownStationInstance, field: "star.title")}</td>

							<td>
                           	 	<richui:teaser length="10" value=" ${ownStationInstance.address}"/>
                            </td>
                           
                            <td><g:formatBoolean boolean="${ownStationInstance.isLocked}" /></td>

                            <td>
								<g:form>
				                    <g:hiddenField name="id" value="${ownStationInstance?.id}" />
				                    <g:if test="${ownStationInstance.isLocked==true}">
				                    	<span class="button"><g:actionSubmit class="unLock" action="unLock" value="${message(code: 'default.button.unLocked.label', default: 'unLocked')}" onclick="return confirm('${message(code: 'default.button.unLocked.confirm.message', default: 'Are you sure?')}');" /></span>
				                    	<span class="button"><g:actionSubmit class="unLock" action="delete" value="${message(code: 'default.button.delete.label', default: 'delete')}" onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');" /></span>
				                	</g:if>
				                	<g:if test="${ownStationInstance.isLocked==false}">
				                    	<span class="button"><g:actionSubmit class="locked" action="locked" value="${message(code: 'default.button.locked.label', default: 'locked')}" onclick="return confirm('${message(code: 'default.button.locked.confirm.message', default: 'Are you sure?')}');" /></span>
				                    	<span class="button"><g:actionSubmit class="unLock" action="delete" value="${message(code: 'default.button.delete.label', default: 'delete')}" onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');" /></span>
				                	</g:if>
				                </g:form>
                            </td>
                            
                            <td>
								<g:form>
				                    <g:hiddenField name="id" value="${ownStationInstance?.id}" />
				                    <g:if test="${ownStationInstance.isActived==true}">
				                    	<span class="button"><g:actionSubmit class="unActive" action="unActived" value="${message(code: 'default.button.unActive.label', default: 'unLocked')}" onclick="return confirm('${message(code: 'default.button.unActived.confirm.message', default: 'Are you sure?')}');" /></span>
				                	</g:if>
				                	<g:if test="${ownStationInstance.isActived==false}">
				                    	<span class="button"><g:actionSubmit class="actived" action="actived" value="${message(code: 'default.button.active.label', default: 'locked')}" onclick="return confirm('${message(code: 'default.button.active.confirm.message', default: 'Are you sure?')}');" /></span>
				                	</g:if>
				                </g:form>
                            </td>
                        </tr>
                    </g:each>
                    </tbody>
                </table>
            </div>
            <div class="paginateButtons">
                <g:paginate total="${ownStationInstanceTotal}" />
            </div>
        </div>
    </body>
</html>
